package com.wawayaya.bookreader.worddict;


import android.text.TextUtils;

public class GenerateDictdescText {

	private GenerateDictdescText(){
	}
	
	public static String generateDictionarydescriptionText(WordDictdescData.WordDictdescItemJieShi[] wdijss, int fontsize, int jieshicolor, int lijucolor){
        String mainColor = "#9CC7F5";
        String jishiColor = "#282828";
        String lijuColor = "#909090";
    	if(null == wdijss || wdijss.length <= 0){
    		return null;
    	}
    	StringBuilder sbtext = new StringBuilder();
    	//int iindex = 1;
    	for(WordDictdescData.WordDictdescItemJieShi wdijs : wdijss) {
    		if(null == wdijs){
    			continue;
    		}
    		if(!TextUtils.isEmpty(wdijs.m_sshiyi)) {
                sbtext.append("<div class=\"div-number\">" +
                        "<font color=" + mainColor + " size=" + fontsize + ">"  + "." + "</font></div>" +
                        "<div class=\"div-str\">" +
                        "<font color=" + mainColor + " size=" + fontsize + ">" + wdijs.m_sshiyi + "</font></div>");
            }
    		//sbtext.append("<p calss=\"separator\">");
    		if(null != wdijs.m_cizus && wdijs.m_cizus.length > 0) {
    				for(WordDictdescData.ParcelableCizu dl : wdijs.m_cizus) {
    					if(null != dl) {
    						if(!TextUtils.isEmpty(dl.m_cizu)){
        	    				sbtext.append("<div class=\"duanyu_c\">" + "<font color=" + jishiColor + " size=" + fontsize + ">" + dl.m_cizu + "</font></div>");
    						}
    						if(!TextUtils.isEmpty(dl.m_cizujieshi)){
        	    				sbtext.append("<div class=\"duanyu_e\">" + "<font color=" + lijuColor + " size=" + fontsize + ">" + dl.m_cizujieshi + "</font></div>");
    						}
                            //sbtext.append("<p calss=\"separator\">");
    					}
    				}
    		}
    		if(null != wdijs.m_lijus && wdijs.m_lijus.length > 0) {
    				for(WordDictdescData.ParcelableCizu dl : wdijs.m_lijus) {
    					if(null != dl) {
    						if(!TextUtils.isEmpty(dl.m_cizu)){
        	    				sbtext.append("<div class=\"liju_c\">" + "<font color=" + jishiColor + " size=" + fontsize + ">" + dl.m_cizu + "</font></div>");
    						}
    						if(!TextUtils.isEmpty(dl.m_cizujieshi)){
        	    				sbtext.append("<div class=\"liju_e\">" + "<font color=" + lijuColor + " size=" + fontsize + ">" + dl.m_cizujieshi + "</font></div>");
    						}
                            //sbtext.append("<p calss=\"separator\">");
    					}
    				}
    		}
    		//sbtext.append("</p>");
    		if(sbtext.length() > 0) {
        			sbtext.append("<style type=\"text/css\">");
        			//sbtext.append(".duanyu_c{text-indent:0;padding:0.2em 2em 0;}");
                    sbtext.append(".duanyu_c{text-indent:0;padding:0em 0em 0.7em 1.0em;}");
        			//sbtext.append(".duanyu_e{text-indent:0;padding:0 2em 0.2em;}");
                    sbtext.append(".duanyu_e{text-indent:0;padding:0em 0em 0.7em 1.0em;}");
        			//sbtext.append(".liju_c{text-indent:0;padding:0.2em 2em 0;}");
                    sbtext.append(".liju_c{text-indent:0;padding:0em 0em 0.7em 1.0em;}");
        			//sbtext.append(".liju_e{text-indent:0;padding:0 2em 0.2em;}");
                    sbtext.append(".liju_e{text-indent:0;padding:0em 0em 0.7em 1.0em;}");
        			//sbtext.append(".div-number{float:left;width:2em;line-height:1.5em;}");
        			//sbtext.append(".div-str{float:left;line-height:1.5em;word-break:break-all;}");
                    //sbtext.append(".div-number{display:inline;width:1.0em;line-height:0.5em;}");
        			//sbtext.append(".div-str{display:inline;line-height:1.0em;padding:0em 0em 1.5em 0.8em;;");
                    sbtext.append(".div-number{float:left;width:0.0em;line-height:0.7em;}");
                    sbtext.append(".div-str{text-indent:0;padding:0em 0em 0.7em 1.0em;}");

        			sbtext.append("</style>"); 
    		}		
    	} // for(WordDictdescItem wdi : wdis)

		return sbtext.toString();
	}

    public static String generateEnDictionaryDescriptionText(EnWordDictDescData.EnWordCiXingData[] cixings, int fontsize, int jieshicolor, int lijucolor){
        String mainColor = "#9CC7F5";
        String jishiColor = "#282828";
        String lijuColor = "#707070";
        String lijujieshiColor = "#909090";
        if(null == cixings || cixings.length <= 0){
            return null;
        }
        StringBuilder sbtext = new StringBuilder();

        for (EnWordDictDescData.EnWordCiXingData cixing : cixings) {
            if (cixing == null) {
                continue;
            }
            if (!TextUtils.isEmpty(cixing.mCXdecs)) {
                sbtext.append("<div class=\"cixing\">" +
                        "<font color=" + mainColor + " size=" + fontsize + ">" + cixing.mCXdecs + "</font></div>");
            }

            if (!TextUtils.isEmpty(cixing.mFuShu)) {
                sbtext.append("<div class=\"fushu\">" +
                        "<font color=" + mainColor + " size=" + fontsize + ">" + cixing.mFuShu + "</font></div>");
            }

            if (sbtext.length() > 0) {
                sbtext.append("<style type=\"text/css\">");
                sbtext.append(".cixing{text-indent:0;padding:0em 0em 0.7em 0.0em;}");
                sbtext.append(".fushu{text-indent:0;padding:0em 0em 0.7em 0.0em;}");
                sbtext.append("</style>");
            }

            if (cixing.mJieShis == null || cixing.mJieShis.length < 0) continue;

            for (EnWordDictDescData.EnWordJieshiData jishi : cixing.mJieShis) {
                if (null == jishi) {
                    continue;
                }
                if (!TextUtils.isEmpty(jishi.mShiYi)) {
                    sbtext.append("<div class=\"div-number\">" +
                            "<font color=" + jishiColor + " size=" + fontsize + ">" + "." + "</font></div>" +
                            "<div class=\"div-str\">" +
                            "<font color=" + jishiColor + " size=" + fontsize + ">" + jishi.mShiYi + "</font></div>");
                }

                if (null != jishi.mLiJus && jishi.mLiJus.length > 0) {
                    for (EnWordDictDescData.EnParcelableCizu lj : jishi.mLiJus) {
                        if (null != lj) {
                            if (!TextUtils.isEmpty(lj.mLiJu)) {
                                sbtext.append("<div class=\"liju_c\">" + "<font color=" + lijuColor + " size=" + fontsize + ">" + lj.mLiJu + "</font></div>");
                            }
                            if (!TextUtils.isEmpty(lj.mLiJuJieShi)) {
                                sbtext.append("<div class=\"liju_e\">" + "<font color=" + lijujieshiColor + " size=" + fontsize + ">" + lj.mLiJuJieShi + "</font></div>");
                            }
                            //sbtext.append("<p calss=\"separator\">");
                        }
                    }
                }
                //sbtext.append("</p>");
                if (sbtext.length() > 0) {
                    sbtext.append("<style type=\"text/css\">");

                    //sbtext.append(".liju_c{text-indent:0;padding:0.2em 2em 0;}");
                    sbtext.append(".liju_c{text-indent:0;padding:0em 0em 0.7em 1.0em;}");
                    //sbtext.append(".liju_e{text-indent:0;padding:0 2em 0.2em;}");
                    sbtext.append(".liju_e{text-indent:0;padding:0em 0em 0.7em 1.0em;}");
                    //sbtext.append(".div-number{float:left;width:2em;line-height:1.5em;}");
                    //sbtext.append(".div-str{float:left;line-height:1.5em;word-break:break-all;}");
                    //sbtext.append(".div-number{display:inline;width:1.0em;line-height:0.5em;}");
                    //sbtext.append(".div-str{display:inline;line-height:1.0em;padding:0em 0em 1.5em 0.8em;;");
                    sbtext.append(".div-number{float:left;width:0.0em;line-height:0.7em;}");
                    sbtext.append(".div-str{text-indent:0;padding:0em 0em 0.7em 1.0em;}");

                    sbtext.append("</style>");
                }
            } // for(WordDictdescItem wdi : wdis)
        }
        return sbtext.toString();
    }
	
}
